﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataOrder_Model" @search="()=>{getTableDataOrder_Model();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OrderType_FormItem" prop="OrderType" :label="$t('message.autotrans._Model_Order_Model_orderType')">
            <el-input v-model="searchDataOrder_Model.OrderType" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OrderCode_FormItem" prop="OrderCode" :label="$t('message.autotrans._Model_Order_Model_orderCode')">
            <el-input v-model="searchDataOrder_Model.OrderCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OrderQty_FormItem" prop="OrderQty" :label="$t('message.autotrans._Model_Order_Model_orderQty')">
            <el-input v-model="searchDataOrder_Model.OrderQty" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Order_Status_FormItem" prop="Order_Status" :label="$t('message.autotrans._Model_Order_Model_order_Status')">
            <el-select v-model="searchDataOrder_Model.Order_Status" clearable>
               <el-option key="CREATE" value="CREATE" :label="$t('message.autotrans._Enum_OrderStatus_CREATE')"></el-option>
               <el-option key="ISSUE" value="ISSUE" :label="$t('message.autotrans._Enum_OrderStatus_ISSUE')"></el-option>
               <el-option key="PRODUCE" value="PRODUCE" :label="$t('message.autotrans._Enum_OrderStatus_PRODUCE')"></el-option>
               <el-option key="STOP" value="STOP" :label="$t('message.autotrans._Enum_OrderStatus_STOP')"></el-option>
               <el-option key="CANCEL" value="CANCEL" :label="$t('message.autotrans._Enum_OrderStatus_CANCEL')"></el-option>
               <el-option key="FINISH" value="FINISH" :label="$t('message.autotrans._Enum_OrderStatus_FINISH')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="MaterialCode_FormItem" prop="MaterialCode" :label="$t('message.autotrans._Model_Order_Model_materialCode')">
            <el-input v-model="searchDataOrder_Model.MaterialCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="MaterialId_FormItem" prop="MaterialId" :label="$t('message.autotrans._Model_Order_Model_materialId')">
            <el-input v-model="searchDataOrder_Model.MaterialId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="MaterialName_FormItem" prop="MaterialName" :label="$t('message.autotrans._Model_Order_Model_materialName')">
            <el-input v-model="searchDataOrder_Model.MaterialName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="MaterialVersion_FormItem" prop="MaterialVersion" :label="$t('message.autotrans._Model_Order_Model_materialVersion')">
            <el-input v-model="searchDataOrder_Model.MaterialVersion" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ScheduleCode_FormItem" prop="ScheduleCode" :label="$t('message.autotrans._Model_Order_Model_scheduleCode')">
            <el-input v-model="searchDataOrder_Model.ScheduleCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ScheduleQty_FormItem" prop="ScheduleQty" :label="$t('message.autotrans._Model_Order_Model_scheduleQty')">
            <el-input v-model="searchDataOrder_Model.ScheduleQty" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ScheduleEditTime_FormItem" prop="ScheduleEditTime" :label="$t('message.autotrans._Model_Order_Model_scheduleEditTime')">
            <el-input v-model="searchDataOrder_Model.ScheduleEditTime" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ScheduleId_FormItem" prop="ScheduleId" :label="$t('message.autotrans._Model_Order_Model_scheduleId')">
            <el-input v-model="searchDataOrder_Model.ScheduleId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ScheduleStationId_FormItem" prop="ScheduleStationId" :label="$t('message.autotrans._Model_Order_Model_scheduleStationId')">
            <el-input v-model="searchDataOrder_Model.ScheduleStationId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="MOrderStatus_FormItem" prop="MOrderStatus" :label="$t('message.autotrans._Model_Order_Model_MOrderStatus')">
            <el-input v-model="searchDataOrder_Model.MOrderStatus" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="WorkshopCode_FormItem" prop="WorkshopCode" :label="$t('message.autotrans._Model_Order_Model_workshopCode')">
            <el-input v-model="searchDataOrder_Model.WorkshopCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="WorkshopName_FormItem" prop="WorkshopName" :label="$t('message.autotrans._Model_Order_Model_workshopName')">
            <el-input v-model="searchDataOrder_Model.WorkshopName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="LineCode_FormItem" prop="LineCode" :label="$t('message.autotrans._Model_Order_Model_lineCode')">
            <el-input v-model="searchDataOrder_Model.LineCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="LineName_FormItem" prop="LineName" :label="$t('message.autotrans._Model_Order_Model_lineName')">
            <el-input v-model="searchDataOrder_Model.LineName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="StationCode_FormItem" prop="StationCode" :label="$t('message.autotrans._Model_Order_Model_stationCode')">
            <el-input v-model="searchDataOrder_Model.StationCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="StationName_FormItem" prop="StationName" :label="$t('message.autotrans._Model_Order_Model_stationName')">
            <el-input v-model="searchDataOrder_Model.StationName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipmentCode_FormItem" prop="EquipmentCode" :label="$t('message.autotrans._Model_Order_Model_equipmentCode')">
            <el-input v-model="searchDataOrder_Model.EquipmentCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="StartTime_FormItem" prop="StartTime" :label="$t('message.autotrans._Model_Order_Model_startTime')">
            <el-input v-model="searchDataOrder_Model.StartTime" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EndTime_FormItem" prop="EndTime" :label="$t('message.autotrans._Model_Order_Model_endTime')">
            <el-input v-model="searchDataOrder_Model.EndTime" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="FactoryCode_FormItem" prop="FactoryCode" :label="$t('message.autotrans._Model_Order_Model_factoryCode')">
            <el-input v-model="searchDataOrder_Model.FactoryCode" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
    <el-popconfirm title="确定同步吗？" @confirm="Synchronous">
            <template #reference>
                <el-button style="width: 100px; height: 32px;margin-right: 10px;" type="primary">基础数据同步</el-button>
            </template>
        </el-popconfirm>
      <WtmButton v-auth="'/api/BaseInformation/Order_Model/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/BaseInformation/Order_Model/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/BaseInformation/Order_Model/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/BaseInformation/Order_Model/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/BaseInformation/Order_Model/Order_ModelExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefOrder_Model" v-bind="tableDataOrder_Model">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/BaseInformation/Order_Model/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/BaseInformation/Order_Model/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/BaseInformation/Order_Model/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageBaseInformationOrder_ModelIndex;true;TyMES.BaseInformation.Controllers;Order_Model">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { order_modelApi } from '/@/api/baseinformation/order_model';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;
import request from '/@/utils/request';

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateOrder_Model = reactive({
    
});

const searchDataOrder_Model = ref({
        OrderType: '',
        OrderCode: '',
        OrderQty: '',
        Order_Status: undefined,
        MaterialCode: '',
        MaterialId: '',
        MaterialName: '',
        MaterialVersion: '',
        ScheduleCode: '',
        ScheduleQty: '',
        ScheduleEditTime: '',
        ScheduleId: '',
        ScheduleStationId: '',
        MOrderStatus: '',
        WorkshopCode: '',
        WorkshopName: '',
        LineCode: '',
        LineName: '',
        StationCode: '',
        StationName: '',
        EquipmentCode: '',
        StartTime: '',
        EndTime: '',
        FactoryCode: '',
});

// 定义变量内容
const tableRefOrder_Model = ref();
const tableDataOrder_Model = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page工单类型'),key: 'Order_Model_orderType',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工单编号'),key: 'Order_Model_orderCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工单数量'),key: 'Order_Model_orderQty',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工单状态'),key: 'Order_Model_order_Status',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page虚拟物料编码'),key: 'Order_Model_materialCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page虚拟物料ID'),key: 'Order_Model_materialId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page虚拟物料名称'),key: 'Order_Model_materialName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page虚拟物料版本'),key: 'Order_Model_materialVersion',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page分工单编码'),key: 'Order_Model_scheduleCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page分工单数量'),key: 'Order_Model_scheduleQty',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page分工单编辑时间'),key: 'Order_Model_scheduleEditTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page分工单ID'),key: 'Order_Model_scheduleId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page分工单站号'),key: 'Order_Model_scheduleStationId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page分工单状态'),key: 'Order_Model_MOrderStatus',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page车间编码'),key: 'Order_Model_workshopCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page车间名称'),key: 'Order_Model_workshopName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产线号'),key: 'Order_Model_lineCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产线名称'),key: 'Order_Model_lineName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page上线工位编码'),key: 'Order_Model_stationCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page上线工位名称'),key: 'Order_Model_stationName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page设备编码'),key: 'Order_Model_equipmentCode',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page开始时间'),key: 'Order_Model_startTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page结束时间'),key: 'Order_Model_endTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工厂编码'),key: 'Order_Model_factoryCode',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataOrder_Model = () => {
    tableRefOrder_Model.value.doSearch(order_modelApi().search, searchDataOrder_Model.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataOrder_Model)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataOrder_Model)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataOrder_Model)
};

// 删除
const onDelete = (row: any) => {
    order_modelApi().delete([row.ID]).then(() => { getTableDataOrder_Model()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefOrder_Model.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      order_modelApi().delete(selectedids).then(() => { getTableDataOrder_Model()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefOrder_Model.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataOrder_Model)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataOrder_Model)
};

const onExport = () => {
	const selected = tableRefOrder_Model.value.getSelectedRows();
	if (selected.length > 0) {
		order_modelApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		order_modelApi().export({});
	}
};
function Synchronous(){
  request({
        url: '/api/baseinformation/operation/autogetorder',
        method: 'get',
        data: {
            'id':''
        }
    })
}

// 页面加载时
onMounted(() => {
    
        getTableDataOrder_Model();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

